﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;

namespace GUI
{
    public partial class frmDangNhap : Form
    {
        public frmDangNhap()
        {
            InitializeComponent();
        }

        private void frmDangNhap_Load(object sender, EventArgs e)
        {

        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frmQuenMatKhau f = new frmQuenMatKhau();
            f.ShowDialog();
        }

        public static string user = "";
        public static string pass = "";
        NguoiDungBUS nd = new NguoiDungBUS();
        frmMain frm = new frmMain();
        private void btDangNhap_Click(object sender, EventArgs e)
        {
            //try
            //{
            user = txtTaiKhoan.Text;
            pass = txtMatKhau.Text;
            if (nd.KiemTraUserPass(user, pass) == true && nd.TinhTrang(user) == "1")
            {
                this.Visible = false;
                frm.ShowDialog();
                this.Close();
            }
            else if (nd.TinhTrang(user) == "0")
            {
                MessageBox.Show("Tai Khoan Cua Ban Da Bi Khoa", "Thong Bao");
            }
            else
            {
                MessageBox.Show("Ban Nhap Pass Hoac User Bi Sai");
            }
            //}
            //catch
            //{
            //    MessageBox.Show("Ket noi khong thanh cong");
            //}
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void lbQuenMatKhau_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frmQuenMatKhau f=new frmQuenMatKhau();
            f.ShowDialog();
        }

        private void lbQuenMatKhau_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frmQuenMatKhau f = new frmQuenMatKhau();
            f.ShowDialog();
        }
    }
}
